package com.lsp.microorder.recharge.consumer;

import com.lsp.microcommon.entity.RechargeInfo;
import com.lsp.microorder.recharge.service.RechargeInfoService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@RabbitListener(queues = "order_queue1")
public class DelayConsumer {

    @Resource
    private RechargeInfoService rechargeInfoService;

    @RabbitHandler
    public void receiveMsg(String orderId){
//        将业务订单设置为取消状态
        RechargeInfo rechargeInfo = rechargeInfoService.rechargeInfo(Integer.valueOf(orderId));
        if(rechargeInfo!=null&&rechargeInfo.getStateFlag().equals(1)){
            rechargeInfoService.updateRechargeStatus(Integer.valueOf(orderId),3);
        }
    }
}
